using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Category("GameObject")]
	[AgentType(typeof(Transform))]
	public class RemoveComponent : ActionTask
	{
		[RequiredField]
		public BBString componentName;

		protected override string info
		{
			get
			{
				return "Remove '" + componentName;
			}
		}

		protected override void OnExecute()
		{
			Component component = base.agent.GetComponent(componentName.value);
			if (component != null)
			{
				Object.Destroy(component);
				EndAction(true);
			}
			else
			{
				EndAction(false);
			}
		}
	}
}
